//
//  DZMReadViewCell.swift
//  DZMeBookRead
//
//  Created by 邓泽淼 on 2017/5/15.
//  Copyright © 2017年 DZM. All rights reserved.
//

import UIKit

class DZMReadViewCell: UITableViewCell {
    
    /// 阅读View 显示使用
    private lazy var readView = DZMReadView()
    
    weak var readController:CLReadViewController? {
        didSet {
            self.readView.readController = self.readController
        }
    }

    /// 当前的显示的内容
    var frameRef:CTFrame? {
        didSet {
            if let frame_ = self.frameRef { // 有值
                self.readView.frameRef = frame_
            }
        }
    }
    
    static func cellWithTableView(_ tableView:UITableView) -> DZMReadViewCell {
        let ID = "DZMReadViewCell"
        var cell = tableView.dequeueReusableCell(withIdentifier: ID) as? DZMReadViewCell
        if (cell == nil) {
            cell = DZMReadViewCell(style: UITableViewCell.CellStyle.subtitle, reuseIdentifier: ID)
        }
        return cell!
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = .none
        self.backgroundColor = UIColor.clear
        self.readView.backgroundColor = UIColor.clear
        self.contentView.addSubview(self.readView)
        self.readView.snp.makeConstraints { (make) in
            make.edges.equalToSuperview()
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        
        fatalError("init(coder:) has not been implemented")
    }
}
